<@master template="master/master-loan"  title="归档管理">
			<div class="detaiTab detaiTab1">
				<form id="subForm"  action="/archive/v1/repeatGdNewDes" class="clearfix" data-action-html="#action_load_body" method="get" id="loanUserForm" >
				 <table border="0" cellpadding="0" cellspacing="0" width="100%">
					 <tr>
						 <td class="bg" align="right" width="15%">贷款单号:</td>
						 <td>
						 	<#if !gdId??>
						 		<input id="billCode" type="text" class="tabInp" name="billCode" value="${loanInfo.billCode}"/>
						 	<#else>
						 		${loanInfo.billCode}
						 	</#if>
						</td>
					</tr>
					<#if !gdId??>
					<tr>
					   <td class="bg"></td>
					   <td>
					   		<span class="red">${errorMsg}</span></br>
					   		<@permission permissionName="DH_BCGD_Query_Des_BTN">
					   			<input type="submit" value="查询" class="btn_auto_30 btn_blue" />
					   		</@permission>
					   	</td>
					 </tr>
					 </#if>
					</table>
				</form>
			</div>
			
			<#if loanInfo??>
			<div class="cktitle"><span class="xiala"></span>贷款资料</div>
			<div id="loanInfoDIv" class="detaiTab detaiTab1">
			<form id="loanInfoForm" action="/archive/v1/repeatGdNewDes" class="action-ajax-form" data-action-html="#action_load_body">
				 <table border="0" cellpadding="0" cellspacing="0" width="100%">
					 <tr>
						 <td class="bg" align="right" width="15%">贷款单号:</td>
						 <td width="35%">${loanInfo.billCode}</td>
						<td class="bg" align="right" width="15%">借款人:</td>
						 <td>${loanInfo.loanUserInfo.userFullName}</td>
					</tr>
					<tr>
						 <td class="bg" align="right" width="15%">放款日期:</td>
						 <td width="35%">${loanInfo.paymentTime}</td>
						<td class="bg" align="right" width="15%">借款期限:</td>
						 <td>${loanInfo.loanTerm}个月</td>
					</tr>
					<tr>
						 <td class="bg" align="right" width="15%">放款银行:</td>
						 <td>${loanInfo.bankLoanName}</td>
						 <td class="bg" align="right" width="15%"><span><font color="red">*</font></span>二次归档类型:</td>
						 <td id="archiveType"  data="${gdRepeatEntity.archiveType}">
						 	<select>
							 	<option>请选择</option>
								<option>信贷资料归档</option>
								<option>代还款确认书归档</option>
								<option>分期还款协议归档</option>
							</select>
						 </td>
					</tr>
					<tr>
						 <td class="bg" align="right" width="15%"><span><font color="red">*</font></span>归档资料类型:</td>
						 <td id="formTypeId" data="${formTypeId}">
						 	<select>
							 	<option>请选择</option>
								<option value="43004">存柜资料</option>
								<option value="43003">财务存柜资料</option>
							</select>
						 </td>
					</tr>
				</table>
			</form>
			</div>
			
		   <div class="cktitle"><span class="xiala"></span>归档资料</div>
		   		<form id="archiveRecordForm" action="/archive/rest/v1/saveRepeatArchiveRecord" class="action-ajax-form" data-action-html="#action_load_body" method="post">
	       		<div class="m10 detaiTab" style="border-right:1px solid #e1e1e1; border-left:1px solid #e1e1e1">
	       			<#if formTypeId?? && formTypeId == "43003"> 
		                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="b_t_e5">
		                    <tbody>
		                        <#list 0..(cwFields?size/3)?ceiling-1 as x> 
		                    	 	<tr>
		                    	 		<#list 0..2 as index> 
			                    	 		<#if cwFields[x*3+index]??>
					                            <td align="right" class="bg " width="15%">${cwFields[x*3+index].fieldName}</td>
					                            <td class="fieldVaule" data="${cwFields[x*3+index].fieldName}">
					                            <select>
					                            	<option>请选择</option>
					                            	<#list cwFields[x*3+index].fieldMin..cwFields[x*3+index].fieldMax as i> 
					                            		<#if cwFields[x*3+index].fieldValue?? && cwFields[x*3+index].fieldValue ==i >
					                            			<option selected="selected">${i}</option>
					                            		<#else>
						                            		<option>${i}</option>
					                            		</#if>
					                            	</#list>
					                            </select>
					                                                       份</td>
			                    	 		<#else>
			                    	 			<td align="right" class="bg" width="15%"></td>
					                            <td></td>
			                    	 		</#if>
		                    	 		</#list>
			                        </tr>
								</#list>
		                    </tbody>
		                </table>
		            <#else>
	            	   <table width="100%" border="0" cellspacing="0" cellpadding="0" class="b_t_e5">
		                    <tbody>
		                        <#list 0..(fields?size/3)?ceiling-1 as x> 
		                    	 	<tr>
		                    	 		<#list 0..2 as index> 
			                    	 		<#if fields[x*3+index]??>
					                            <td align="right" class="bg " width="15%">${fields[x*3+index].fieldName}</td>
					                            <td class="fieldVaule" data="${fields[x*3+index].fieldName}">
					                            <select>
					                            	<option>请选择</option>
					                            	<#list fields[x*3+index].fieldMin..fields[x*3+index].fieldMax as i> 
					                            		<#if fields[x*3+index].fieldValue?? && fields[x*3+index].fieldValue ==i >
					                            			<option selected="selected">${i}</option>
					                            		<#else>
						                            		<option>${i}</option>
					                            		</#if>
					                            	</#list>
					                            </select>
					                                                       份</td>
			                    	 		<#else>
			                    	 			<td align="right" class="bg" width="15%"></td>
					                            <td></td>
			                    	 		</#if>
		                    	 		</#list>
			                        </tr>
								</#list>
		                    </tbody>
		                </table>  
	                </#if>
	            </div>
	            <div class=" mtb20 tac">
				  	<span id="archiveErrorMsg" style="disploy:none;" class="red"></span></br>
		            <#if isHideBtn == 1>
			            <@permission permissionName="DH_BCGD_Add_Des_BTN">
				            <a id="saveBtn" href="javascript:void(0);" class="btn_auto_30 btn_blue">保 存</a>
		                </@permission>
						<#if gdId??>
							<@permission permissionName="DH_BCGD_Delete_Des_BTN">
								<a href="/archive/rest/v1/deleteRepeatArchiveRecord?gdId=${gdId}&billCode=${loanInfo.billCode}" class="btn_auto_30 btn_blue action-ajax-btn">删除</a>
							</@permission>
							<@permission permissionName="DH_BCGD_Start_Des_BTN">
								<a href="/archive/rest/v1/gdRepeatStart?gdId=${gdId}&billCode=${loanInfo.billCode}" class="btn_auto_30 btn_blue action-ajax-btn">启动流程</a>
							</@permission>
						</#if>
					</#if>
					<@permission permissionName="DH_BCGD_Return_Des_BTN">
						<a href="/archive/v1/repeatGdList?billCode=${loanInfo.billCode}" class="btn_auto_30 btn_blue">返回列表</a>
					</@permission>
				</div>
	            <input name="loanapplyNo" type="hidden" value="${loanInfo.loanapplyNo}"/>
	            <input name="bankTypeId" type="hidden" value="${bankTypeId}"/>
	            <input id="contentJson" name="contentJson" type="hidden"/>
	            <input id="cwContentJson" name="cwContentJson" type="hidden"/>
	            <input id="formTypeIdHide" name="formTypeId" type="hidden"/>
	            <input id="archiveTypeHide" name="archiveType" type="hidden"/>
	            <input id="gdId" name="id" type="hidden" value="${gdId}"/>
	            <input id="billCode" name="billCode" type="hidden" value="${loanInfo.billCode}"/>
	            </form>
	    </div>
    	</#if>
</@master>
<@js>
	if($('#archiveType').attr("data")){
		$('#archiveType select').val($('#archiveType').attr("data"));
	}
	if($('#formTypeId').attr("data")){
		$('#formTypeId select').val($('#formTypeId').attr("data"));
	}
	if(!$('#saveBtn').text()){
		$('#loanInfoDIv select').attr("disabled","disabled");
		$('#archiveRecordForm select').attr("disabled","disabled");
	}
	$("#formTypeId").change(function(event){
		var dgId = $('#gdId').val();
		var billCode = $('#billCode').val();
		var formTypeId = event.target.value;
		if(dgId){
			window.location.href="/archive/v1/repeatGdNewDes?gdId=" + dgId + "&billCode=" + billCode+"&formTypeId="+formTypeId;
		}
	});
	
	$("#saveBtn").click(function(){
		if($('#archiveType select').val() == "请选择"){
			$('#archiveErrorMsg').text("二次归档类型不能为空").show();
			return;
		}
		if($('#formTypeId select').val() == "请选择"){
			$('#archiveErrorMsg').text("归档资料类型不能为空").show();
			return;
		}
		var formTypeId = $('#formTypeId select').val();
		$('#formTypeIdHide').val(formTypeId);
		$('#archiveTypeHide').val($('#archiveType select').val());
		var contentJson = {};
		$('#archiveRecordForm table').find('.fieldVaule').each(function(f,field){
			var key=$(field).attr('data');
			var value=$(field).find('select').val();
			if(value !="请选择" ){
				contentJson[key]=value;
			}
		});
		if(formTypeId == '43003')
			$('#cwContentJson').val(JSON.stringify(contentJson));
		else
			$('#contentJson').val(JSON.stringify(contentJson));
		$('#archiveType select').val()
		$('#archiveErrorMsg').text('').hide();
		$('#archiveRecordForm').submit();
   });
</@js>
<@jsRender/>